package com.cs.service;

import com.cs.mapper.PricepeopleMapper;
import com.cs.pojo.Pricepeople;
import com.cs.pojo.PricepeopleExample;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
public class PricepeopleService {
    
    @Resource
    private PricepeopleMapper pricepeopleMapper;
    
    // 是否指定 主键进行查询
    @Transactional (propagation = Propagation.REQUIRES_NEW, readOnly = true)
    public List<Pricepeople> queryById(int id , boolean bool){
        PricepeopleExample example = new PricepeopleExample();
        PricepeopleExample.Criteria criteria = example.createCriteria();
        if (bool) {
            criteria.andChapIdEqualTo(id);
        }else{
            criteria.andBehIdEqualTo(id);
        }
        return pricepeopleMapper.selectByExample(example);
    }
    
}
